<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>角色表单</title>
  <link rel="stylesheet" href="${ctx}/static/admin/layui/css/layui.css">
  </head>
    <body>
    <div class="layui-card-body">
  	<form class="layui-form layui-form-pane">
	  <input name="id" type="hidden" value="${role.id! }" />
	  <div class="layui-form-item">
	    <label class="layui-form-label">角色名称</label>
	    <div class="layui-input-block">
	      <input type="text" name="name" lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input" value="${role.name! }">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">排序</label>
	    <div class="layui-input-block">
	      <input type="text" name="seq" lay-verify="required" placeholder="请输入序号" autocomplete="off" class="layui-input" value="${role.seq! }">
	    </div>
	  </div>
	  <div class="layui-form-item layui-form-text">
	    <label class="layui-form-label">备注</label>
	    <div class="layui-input-block">
	      <textarea name="des" placeholder="请输入备注" class="layui-textarea">${role.des! }</textarea>
	    </div>
	  </div>
	  <div class="layui-form-item" style="display: none">
	    <div class="layui-input-block">
	      <button class="layui-btn" id="submit-btn" lay-submit>立即提交</button>
	      <button type="reset" id="reset-btn" class="layui-btn">重置</button>
	    </div>
	  </div>
	</form>
	</div>
  </body>
</html>
<script src="${ctx}/static/admin/layui/layui.js"></script>
<script>
var table;
layui.use(['jquery','form'], function(){
  var $ = jQuery = layui.$;
  var form = layui.form;
  
  if ($(':input[name="id"]').val().length > 0) {
		$(':input[name="name"]').attr('disabled','disabled');
  }
  
  //监听提交
  form.on('submit', function(data){
	  $.post('${ctx}/sys_admin/sys/role/save', data.field, function(result) {
			if (result.success) {
				table.reload({});
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index); //再执行关闭   
			} else {
				layer.msg(result.msg);
			}
		}, 'json');
	  return false;
  });
});
</script>